<?php
	#-------------------------------------------------------------#
	# This file is part of the Kumomado - Virtual Window Platform #
	# for PHP. (c) 2009 Tsai, Min Che <tirme0812@gmail.com>       #
	# Please visit http://www.kumomado.org/ for more information. #
	#                                                             #
	# This software is licensed under the GNU License v3. Please  #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#

	/**
	 * @package libraries
	 * @subpackage criteria
	 * @author Tsai, Min Che
	 */
	abstract class KumomadoCriteriaElement {
		/**
		 * @var string
		 */
		protected $order = 'ASC';
		/**
		 * @var string
		 */
		protected $sort = '';
		/**
		 * @var int
		 */
		protected $limit = 0;
		/**
		 * @var int
		 */
		protected $start = 0;
		/**
		 * @var string
		 */
		protected $group_by = '';
		/**
		 * Construct
		 */
		public function __construct() {}
		/**
		 * Render the criteria element
		 */
		abstract public function render();
		/**
		 * Make a SQL "WHERE" clause
		 */
		abstract public function renderWhere();
		/**
		 * @param string $sort
		 */
		public function setSort($sort) {
			$this->sort = $sort;
		}
		/**
		 * @return string $sort
		 */
		public function getSort() {
			return $this->sort;
		}
		/**
		 * @param string $order DESC or ASC
		 */
		public function setOrder($order) {
			$this->order = 'DESC' == strtoupper($order) ? 'DESC' : 'ASC';
		}
		/**
		 * @return string $order
		 */
		public function getOrder() {
			return $this->order;
		}
		/**
		 * @param int $limit[optional]
		 */
		public function setLimit($limit = 0) {
			$this->limit = intval($limit);
		}
		/**
		 * @return int $limit
		 */
		public function getLimit() {
			return $this->limit;
		}
		/**
		 * @param int $start[optional]
		 */
		public function setStart($start = 0) {
			$this->start = intval($start);
		}
		/**
		 * @return int $start
		 */
		public function getStart() {
			return $this->start;
		}
		/**
		 * @param string $group_by
		 */
		public function setGroupBy($group_by) {
			$this->groupBy = $group_by;
		}
		/**
		 * @return string
		 */
		public function getGroupBy() {
			return ' GROUP BY '.$this->group_by;
		}
	}
?>